package com.qfedu.controller;

import com.github.pagehelper.PageInfo;
import com.qfedu.entity.Customerinfo;
import com.qfedu.service.CustomerService;
import com.qfedu.util.PageHelperUtil;
import com.qfedu.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * projectName: logistics
 * author: CGY
 * time: 2020/10/6 11:04
 * description:
 */
@Controller
@RequestMapping("/customer")
public class CustomerController {
    @Autowired
    private CustomerService customerService;

    @RequestMapping("/addCus.do")
    @ResponseBody
    public Result addCus(Customerinfo customerinfo) {
        Result ret = customerService.addCus(customerinfo);
        return ret;
    }

    @RequestMapping("/selectAllCus.do")
    @ResponseBody
    public PageHelperUtil selectAllCus(Integer pageNum, Integer limit) {
        PageInfo pageInfo = customerService.selectAllCus(pageNum, limit);

        return PageHelperUtil.success(pageInfo.getTotal(), pageInfo.getList());
    }

    @RequestMapping("/selectCusByCode.do")
    @ResponseBody
    public Result selectCusByCode(String customerCode) {

        Result ret = customerService.selectCusByCode(customerCode);
        return ret;
    }
    @RequestMapping("/deleteCus.do")
    @ResponseBody
    public Result deleteCus(String customerCode){
        Result ret = customerService.deleteCus(customerCode);
        return ret;
    }

    @RequestMapping("/updateCustomerInfo.do")
    @ResponseBody
    public Result updateCustomerInfo(Customerinfo customerinfo){
        Result ret = customerService.updateCustomerInfo(customerinfo);
        return ret;
    }

    @RequestMapping("/selectAllCusCode.do")
    @ResponseBody
    public Result selectAllCusCode(){
        return customerService.selectAllCusCode();
    }

}
